import { useState } from "react";


/**
 * useWindosScroll 获取滚动条到顶部的距离
 * @returns value（number）
 */
export function useWindosScroll(){
    const [y,sety]=useState(0)
    window.addEventListener('scroll',()=>{
        let h= document.documentElement.scrollTop
        sety(h)
    })
    return y

}




export function loadShaderFromFile(filename:string) {
    return new Promise((resolve, reject) => {
      
      var request = new XMLHttpRequest();
      request.onreadystatechange = function () {
        if (request.readyState === 4 && request.status === 200) {
            console.log('12312')
          resolve(request.responseText);
        }
      };
      request.open("GET", filename, true);
      request.send();
    })
  
  }